class Solution
{
public:
    int maximumSum(vector<int> &arr)
    {
        int n = arr.size();
        vector<vector<int>> dp(2, vector<int>(n));
        dp[0][0] = arr[0];
        dp[1][0] = 0;

        int result = arr[0];
        for (int i = 1; i < n; ++i)
        {
            dp[0][i] = max(dp[0][i - 1], 0) + arr[i];
            dp[1][i] = max(dp[0][i - 1], dp[1][i - 1] + arr[i]);
            result = max({result, dp[0][i], dp[1][i]});
        }
        return result;
    }
};